|
[ Intro ] [ Lesson1 ] [ Lesson2 ] [ Lesson3 ] [ Lesson4 ] [ Lesson5 ] [ Lesson6 ] [ Lesson7 ] [ Lesson8 ] |
||||||||||
|
So... then let us look at some live actual aiming scripts. And obviosly
to move a piece (like "turret" or "barrel"),
that part has to exist. Many game crashes can be related to that.
This is the script we just examined in Lesson 3. It's quite simple. Note that the amining around the y-axis is set to the angle value "heading". Same thing counts for "pitch", but due to the bug in the engine, you have to invert the value by setting it to "<0> - pitch", or it will aim downwards and look silly. Two lines orders the script to wait until the aiming is completed before opening fire. This is standard procedure, since we normally don't want things to fire square left at a moment's notice.
In case you want to simulate the fire alteration of a real gun, this
script will make an animation pause just after the unit have fired 30
shots. You have to define the static var "reloader"
and you have to insert a row in FirePrimary( ) - function to
get it to work.A lot of preparations, but the it's certainly worth the
while.
Now, we are talking about a forward-fire cannon only. It will lock at anything between 45 degrees to left and as much to right, giving the weapon a 90 degree forward span. You will notice quite soon if you set the minus signs and angle values right when you test the unit in the game. The && signs in the while( ) - argument means "and" in normal language. When both of the asked conditions are set, the script will execute the containment within the function. Otherwise not. There is a kill signal embedded in the while( ) - function, so that the program don't get stuck there forever. In the same way, it is possible to make weapons that fire backwards or sideways only. It's even technically possible to forbid the weapon to aim every other degree, wherever there is anyone that would want such aiming anyway.
This instant will animate two completely different turrets (that need
to have separate names and separate parts in the 3D model) depending on
if the enemy is to the left or to the right of the unit. Useful for large
ships where you don't want different cannons to turn and fire straight
through each other or when you just want certain cannons to aim in certain
angles.
Congratulations, if you mastered this part, you can continue reading Lesson 3. |
||||||||||
| Storm | ||||||||||